require.config(r_config);
require(['user_info','post_item','common','mylayer'], function (user_info,post_item,md_common,mylayer){
	var user_wish={
		init:function(){
			var _this=this;
			user_info.init(this);
		},
		scroll:function(){
			var _this=this;
			var water=$(".water_box");
			var list_loading=water.find(".list_loading");
			var pageCount=parseInt(list_loading.attr("pageCount"))?list_loading.attr("pageCount"):1;
			var total=parseInt(list_loading.attr("total"))?list_loading.attr("total"):0;
			if(pageCount>1){
				var water_container=water.find(".water_container");
				//滚动加载数据
				$(window).on("scroll",function(){
					if(list_loading.size()==0){
						return false;
					}
					var item_number=$(".share_list").size();
					if(item_number>=total){
						return false;
					}
					var top=water.offset().top;
					var height=water.height();
					if(top+height<=md_common.getScrollTop()+md_common.getWindowHeight()){
						var isLoad=list_loading.hasClass("loadlist")?true:false;
						if(!isLoad){
							list_loading.addClass('loadlist').show();
							var url=list_loading.attr("url");
							var data={'offset':item_number};
					        $.postAjax(url,data,function(result){
				        		if(result.list){
				        			var html=_this.getListInfo(result.list);
				        			water_container.append(html);
				        			$(".water_container .lazy").lazyload({
									    threshold : 200
									});
								}
								list_loading.hide().removeClass('loadlist');
					        });
						}
					}
				});
			}
		},
		getListInfo:function(data){
			var html='';
			$.each(data,function(key,list){
				if($("#share_list"+key).size()==0){
					html+=list;
				}
			});
			return html;
		}
	}
	user_wish.init();
});
